package com.keeson.android_cli.ui.main;

import android.view.View;
import androidx.lifecycle.Observer;
import com.gyf.immersionbar.ImmersionBar;
import com.keeson.android_cli.R;
import com.keeson.android_cli.base.BaseMvpActivity;
import com.keeson.android_cli.bean.EmptyObj;
import com.keeson.android_cli.databinding.ActivityMainBinding;
import com.keeson.android_cli.interfaces.contract.LoginContract;
import com.keeson.android_cli.presenter.LoginPresenter;
import com.keeson.android_cli.util.CustomToast;
import com.keeson.android_cli.util.LiveDataBus;


public class MainActivity extends BaseMvpActivity<ActivityMainBinding, LoginContract.Presenter> implements LoginContract.View, View.OnClickListener {
    @Override
    public void initView() {
        ImmersionBar.setStatusBarView(this, binding.fakeStatusBar);
        binding.tvVale.setOnClickListener(this);
        binding.tobBar.ivBack.setOnClickListener(this);
    }

    @Override
    public void initData() {
        LiveDataBus.get()
                .with("key_test", String.class)
                .observe(this, new Observer<String>() {
                    @Override
                    public void onChanged(String s) {
                        CustomToast.INSTANCE.showToast(context,s+"");
                    }
                });
    }


    @Override
    public LoginPresenter initPresenter() {
        return new LoginPresenter(this);
    }


    @Override
    public void getCodeSuccess(EmptyObj data) {

    }



    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tvVale:
                    //mPresenter.getCode("13957364530","86");
                    LiveDataBus.get().with("key_test").setValue("你好");
                break;
            case R.id.iv_back:
                    finish();
                break;

        }
    }
}